package ce.com.cenewbluesdk.entity.k2;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Administrator on 2015/7/3.
 */
public class K2_SendAlarmInfoStruct implements Parcelable {

    // 周重复设置
    byte week_repeat;
    byte hour;
    byte min;
    byte switchState;


    public K2_SendAlarmInfoStruct(byte week_repeat, byte hour, byte min, byte switchState) {
        this.week_repeat = week_repeat;
        this.hour = hour;
        this.min = min;
        this.switchState=switchState;
    }

    protected K2_SendAlarmInfoStruct(Parcel in) {
        week_repeat = in.readByte();
        hour = in.readByte();
        min = in.readByte();
        switchState = in.readByte();
    }

    public static final Creator<K2_SendAlarmInfoStruct> CREATOR = new Creator<K2_SendAlarmInfoStruct>() {
        @Override
        public K2_SendAlarmInfoStruct createFromParcel(Parcel in) {
            return new K2_SendAlarmInfoStruct(in);
        }

        @Override
        public K2_SendAlarmInfoStruct[] newArray(int size) {
            return new K2_SendAlarmInfoStruct[size];
        }
    };

    public byte getSwitchState() {
        return switchState;
    }

    public void setSwitchState(byte switchState) {
        this.switchState = switchState;
    }

    public byte getWeek_repeat() {
        return week_repeat;
    }

    public void setWeek_repeat(byte week_repeat) {
        this.week_repeat = week_repeat;
    }

    public byte getHour() {
        return hour;
    }

    public void setHour(byte hour) {
        this.hour = hour;
    }

    public byte getMin() {
        return min;
    }

    public void setMin(byte min) {
        this.min = min;
    }

    public byte[] getBytes() {

        byte[] bytes = new byte[getItemSize()];
        bytes[0] = week_repeat;
        bytes[1] = hour;
        bytes[2] = min;
        bytes[3] = switchState;
        return bytes;
    }

    public static int getItemSize() {
        /**
         * 闹钟有效数据3字节
         *  typedef struct
         {
         unsigned char week_repeat; // week alarm repeat bit set
         unsigned char hour;
         unsigned char min;
         }alarm_info_struct;
         *
         */
        return 4;
    }

    @Override
    public String toString() {
        return "Send_Alarm_Info_Struct_K3{" +
                            "week_repeat=" + week_repeat +
                            ", hour=" + hour +
                            ", min=" + min +
                            ", switchState=" + switchState +
                            '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte(week_repeat);
        dest.writeByte(hour);
        dest.writeByte(min);
        dest.writeByte(switchState);
    }
}
